home *** CD-ROM | disk | FTP | other *** search
Wrap
rrrreeeeggggeeeexxxxpppprrrr((((3333GGGG)))) rrrreeeeggggeeeexxxxpppprrrr((((3333GGGG)))) NNNNAAAAMMMMEEEE _rrrr_eeee_gggg_eeee_xxxx_pppp_rrrr: _cccc_oooo_mmmm_pppp_iiii_llll_eeee, _ssss_tttt_eeee_pppp, _aaaa_dddd_vvvv_aaaa_nnnn_cccc_eeee - regular expression compile and match routines SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS _cccc_cccc [_f_l_a_g ...] _f_i_l_e ... _----_llll_gggg_eeee_nnnn [_l_i_b_r_a_r_y ...] _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_rrrr_eeee_gggg_eeee_xxxx_pppp_rrrr_...._hhhh_>>>> _cccc_hhhh_aaaa_rrrr _****_cccc_oooo_mmmm_pppp_iiii_llll_eeee _((((_cccc_oooo_nnnn_ssss_tttt _cccc_hhhh_aaaa_rrrr _****_i_n_s_t_r_i_n_g_,,,, _cccc_hhhh_aaaa_rrrr _****_e_x_p_b_u_f_,,,, _cccc_hhhh_aaaa_rrrr _****_e_n_d_b_u_f_))))_;;;; _iiii_nnnn_tttt _ssss_tttt_eeee_pppp _((((_cccc_oooo_nnnn_ssss_tttt _cccc_hhhh_aaaa_rrrr _****_s_t_r_i_n_g_,,,, _cccc_hhhh_aaaa_rrrr _****_e_x_p_b_u_f_))))_;;;; _iiii_nnnn_tttt _aaaa_dddd_vvvv_aaaa_nnnn_cccc_eeee _((((_cccc_oooo_nnnn_ssss_tttt _cccc_hhhh_aaaa_rrrr _****_s_t_r_i_n_g_,,,, _cccc_hhhh_aaaa_rrrr _****_e_x_p_b_u_f_))))_;;;; _eeee_xxxx_tttt_eeee_rrrr_nnnn _cccc_hhhh_aaaa_rrrr _****_llll_oooo_cccc_1111_,,,, _****_llll_oooo_cccc_2222_,,,, _****_llll_oooo_cccc_ssss_;;;; _eeee_xxxx_tttt_eeee_rrrr_nnnn _iiii_nnnn_tttt _nnnn_bbbb_rrrr_aaaa_,,,, _rrrr_eeee_gggg_eeee_rrrr_rrrr_nnnn_oooo_,,,, _rrrr_eeee_gggg_llll_eeee_nnnn_gggg_tttt_hhhh_;;;; _eeee_xxxx_tttt_eeee_rrrr_nnnn _cccc_hhhh_aaaa_rrrr _****_bbbb_rrrr_aaaa_ssss_llll_iiii_ssss_tttt_[[[[_]]]]_,,,, _****_bbbb_rrrr_aaaa_eeee_llll_iiii_ssss_tttt_[[[[_]]]]_;;;; DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN These routines are used to compile regular expressions and match the compiled expressions against lines. The regular expressions compiled are in the form used by _eeee_dddd. The syntax of the _cccc_oooo_mmmm_pppp_iiii_llll_eeee routine is as follows: _cccc_oooo_mmmm_pppp_iiii_llll_eeee _((((_iiii_nnnn_ssss_tttt_rrrr_iiii_nnnn_gggg_,,,, _eeee_xxxx_pppp_bbbb_uuuu_ffff_,,,, _eeee_nnnn_dddd_bbbb_uuuu_ffff_)))) The parameter _i_n_s_t_r_i_n_g is a null-terminated string representing the regular expression. The parameter _e_x_p_b_u_f points to the place where the compiled regular expression is to be placed. If _e_x_p_b_u_f is _NNNN_UUUU_LLLL_LLLL, _cccc_oooo_mmmm_pppp_iiii_llll_eeee uses _mmmm_aaaa_llll_llll_oooo_cccc to allocate the space for the compiled regular expression. If an error occurs, this space is freed. It is the user's responsibility to free unneeded space after the compiled regular expression is no longer needed. The parameter _e_n_d_b_u_f is one more than the highest address where the compiled regular expression may be placed. This argument is ignored if _e_x_p_b_u_f is _NNNN_UUUU_LLLL_LLLL. If the compiled expression cannot fit in (_e_n_d_b_u_f-_e_x_p_b_u_f) bytes, _cccc_oooo_mmmm_pppp_iiii_llll_eeee returns _NNNN_UUUU_LLLL_LLLL and _rrrr_eeee_gggg_eeee_rrrr_rrrr_nnnn_oooo (see below) is set to 50. If _cccc_oooo_mmmm_pppp_iiii_llll_eeee succeeds, it returns a non-_NNNN_UUUU_LLLL_LLLL pointer whose value depends on _e_x_p_b_u_f. If _e_x_p_b_u_f is non-_NNNN_UUUU_LLLL_LLLL, _cccc_oooo_mmmm_pppp_iiii_llll_eeee returns a pointer to the byte after the last byte in the compiled regular expression. The length of the compiled regular expression is stored in _rrrr_eeee_gggg_llll_eeee_nnnn_gggg_tttt_hhhh. Otherwise, _cccc_oooo_mmmm_pppp_iiii_llll_eeee returns a pointer to the space allocated by _mmmm_aaaa_llll_llll_oooo_cccc. PPPPaaaaggggeeee 1111 rrrreeeeggggeeeexxxxpppprrrr((((3333GGGG)))) rrrreeeeggggeeeexxxxpppprrrr((((3333GGGG)))) If an error is detected when compiling the regular expression, a _NNNN_UUUU_LLLL_LLLL pointer is returned from _cccc_oooo_mmmm_pppp_iiii_llll_eeee and _rrrr_eeee_gggg_eeee_rrrr_rrrr_nnnn_oooo is set to one of the non- zero error numbers indicated below: ERROR MEANING _____________________________________________ 11 Range endpoint too large. 16 Bad number. 25 ``_\\\\digit'' out of range. 36 Illegal or missing delimiter. 41 No remembered search string. 42 _\\\\_((((_~~~~_\\\\_)))) imbalance. 43 Too many _\\\\_((((. 44 More than 2 numbers given in _\\\\_{{{{_~~~~_\\\\_}}}}. 45 _}}}} expected after _\\\\. 46 First number exceeds second in _\\\\_{{{{_~~~~_\\\\_}}}}. 49 _[[[[ _]]]] imbalance. 50 Regular expression overflow. The call to _ssss_tttt_eeee_pppp is as follows: _ssss_tttt_eeee_pppp _((((_ssss_tttt_rrrr_iiii_nnnn_gggg_,,,, _eeee_xxxx_pppp_bbbb_uuuu_ffff_)))) The first parameter to _ssss_tttt_eeee_pppp is a pointer to a string of characters to be checked for a match. This string should be null-terminated. The parameter _e_x_p_b_u_f is the compiled regular expression obtained by a call of the function _cccc_oooo_mmmm_pppp_iiii_llll_eeee. The function _ssss_tttt_eeee_pppp returns non-zero if the given string matches the regular expression, and zero if the expressions do not match. If there is a match, two external character pointers are set as a side effect to the call to _ssss_tttt_eeee_pppp. The variable set in _ssss_tttt_eeee_pppp is _llll_oooo_cccc_1111. _llll_oooo_cccc_1111 is a pointer to the first character that matched the regular expression. The variable _llll_oooo_cccc_2222 points to the character after the last character that matches the regular expression. Thus if the regular expression matches the entire line, _llll_oooo_cccc_1111 points to the first character of _s_t_r_i_n_g and _llll_oooo_cccc_2222 points to the null at the end of _s_t_r_i_n_g. The purpose of _ssss_tttt_eeee_pppp is to step through the _s_t_r_i_n_g argument until a match is found or until the end of _s_t_r_i_n_g is reached. If the regular expression begins with _^^^^, _ssss_tttt_eeee_pppp tries to match the regular expression at the beginning of the string only. The function _aaaa_dddd_vvvv_aaaa_nnnn_cccc_eeee has the same arguments and side effects as _ssss_tttt_eeee_pppp, but it always restricts matches to the beginning of the string. If one is looking for successive matches in the same string of characters, _llll_oooo_cccc_ssss should be set equal to _llll_oooo_cccc_2222, and _ssss_tttt_eeee_pppp should be called with _s_t_r_i_n_g equal to _llll_oooo_cccc_2222. _llll_oooo_cccc_ssss is used by commands like _eeee_dddd and _ssss_eeee_dddd so that global substitutions like _ssss_////_yyyy_****_////_////_gggg do not loop forever, and is _NNNN_UUUU_LLLL_LLLL by default. PPPPaaaaggggeeee 2222 rrrreeeeggggeeeexxxxpppprrrr((((3333GGGG)))) rrrreeeeggggeeeexxxxpppprrrr((((3333GGGG)))) The external variable _nnnn_bbbb_rrrr_aaaa is used to determine the number of subexpressions in the compiled regular expression. _bbbb_rrrr_aaaa_ssss_llll_iiii_ssss_tttt and _bbbb_rrrr_aaaa_eeee_llll_iiii_ssss_tttt are arrays of character pointers that point to the start and end of the _nnnn_bbbb_rrrr_aaaa subexpressions in the matched string. For example, after calling _ssss_tttt_eeee_pppp or _aaaa_dddd_vvvv_aaaa_nnnn_cccc_eeee with string _ssss_aaaa_bbbb_cccc_dddd_eeee_ffff_gggg and regular expression _\\\\_((((_aaaa_bbbb_cccc_dddd_eeee_ffff_\\\\_)))), _bbbb_rrrr_aaaa_ssss_llll_iiii_ssss_tttt_[[[[_0000_]]]] will point at _aaaa and _bbbb_rrrr_aaaa_eeee_llll_iiii_ssss_tttt_[[[[_0000_]]]] will point at _gggg. These arrays are used by commands like _eeee_dddd and _ssss_eeee_dddd for substitute replacement patterns that contain the _\\\\_n notation for subexpressions. Note that it isn't necessary to use the external variables _rrrr_eeee_gggg_eeee_rrrr_rrrr_nnnn_oooo, _nnnn_bbbb_rrrr_aaaa, _llll_oooo_cccc_1111, _llll_oooo_cccc_2222 _llll_oooo_cccc_ssss, _bbbb_rrrr_aaaa_eeee_llll_iiii_ssss_tttt, and _bbbb_rrrr_aaaa_ssss_llll_iiii_ssss_tttt if one is only checking whether or not a string matches a regular expression. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS The following is similar to the regular expression code from _gggg_rrrr_eeee_pppp: _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_rrrr_eeee_gggg_eeee_xxxx_pppp_rrrr_...._hhhh_>>>> _.... _.... _.... _iiii_ffff_((((_cccc_oooo_mmmm_pppp_iiii_llll_eeee_((((_****_aaaa_rrrr_gggg_vvvv_,,,, _((((_cccc_hhhh_aaaa_rrrr _****_))))_0000_,,,, _((((_cccc_hhhh_aaaa_rrrr _****_))))_0000_)))) _====_==== _((((_cccc_hhhh_aaaa_rrrr _****_))))_0000_)))) _rrrr_eeee_gggg_eeee_rrrr_rrrr_((((_rrrr_eeee_gggg_eeee_rrrr_rrrr_nnnn_oooo_))))_;;;; _.... _.... _.... _iiii_ffff _((((_ssss_tttt_eeee_pppp_((((_llll_iiii_nnnn_eeee_bbbb_uuuu_ffff_,,,, _eeee_xxxx_pppp_bbbb_uuuu_ffff_))))_)))) _ssss_uuuu_cccc_cccc_eeee_eeee_dddd_((((_))))_;;;; SSSSEEEEEEEE AAAALLLLSSSSOOOO _eeee_dddd(1), _gggg_rrrr_eeee_pppp(1), _ssss_eeee_dddd(1), _rrrr_eeee_gggg_eeee_xxxx_pppp(5) PPPPaaaaggggeeee 3333